package com.xxxx.server.conventer;

import org.apache.tomcat.jni.Local;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @Author:王亚栋
 * @Date: 2023/6/18 下午4:55
 * @Version:1.0
 * 日期转换
 */
@Component
public class DateConverter implements Converter<String,LocalDate> {


    @Override
    public LocalDate convert(String source) {

        try{

            return LocalDate.parse(source, DateTimeFormatter.ofPattern("yyyy-MM-dd"));

        }catch (Exception e){

            e.printStackTrace();
        }

        return null;
    }
}
